package com.project.common.config.mybatis;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.util.Date;

@Component
public class FieldAutoFillHandler implements MetaObjectHandler {
    @Override
    public void insertFill(MetaObject metaObject) {  //字段插入时填充的数据
        metaObject.setValue("gmtCreate",new Date());   //设置那个字段需要自动配置，配置内容是什么
        metaObject.setValue("gmtModified",new Date());
    }

    @Override
    public void updateFill(MetaObject metaObject) {  //字段更新时插入的数据
        metaObject.setValue("gmtModified",new Date());
    }
}